package com.hlb.zh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hlb.zh.dao.StudentsMapper;
import com.hlb.zh.page.Page;
import com.hlb.zh.pojo.Students;
import com.hlb.zh.pojo.StudentsExample;
import com.hlb.zh.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2016/12/16.
 */
@Service
public class StudentServiceimpl implements StudentService{
    @Autowired
    StudentsMapper studentsMapper;
    public List<Students> findAll() throws Exception {
        return studentsMapper.selectByExample(null);
    }

    public  Page<Students>  getPage(int pageNo,int pageSize) throws Exception {
        Page<Students> page=new Page<Students>();
        page.setPageSize(pageSize) ;
       StudentsExample studentsExample=new StudentsExample();
        PageHelper.startPage(pageNo,page.getPageSize());
        List<Students> studentses=studentsMapper.selectByExample(studentsExample);
        page.setList(studentses);
        page.setPageInfo(new PageInfo<Students>(studentses));
        System.out.println(page);
        return page;
    }

}
